package apdate

import activity.QuestionXqActivity
import android.content.Context
import android.content.Intent
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.wd.common.bean.QuestionBean
import com.wd.rim.R

class QuestionApdate(var context: Context, var list: QuestionBean)
    : RecyclerView.Adapter<QuestionApdate.ViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): QuestionApdate.ViewHolder {
        val inflate = LayoutInflater.from(context).inflate(R.layout.item_question, parent, false)
        return ViewHolder(inflate)
    }

    override fun onBindViewHolder(holder: QuestionApdate.ViewHolder, position: Int) {
            holder.name.setText(list.result.get(position).content
            )
        Log.i("sdfsedfsdf", "onBindViewHolder: "+list.result.get(position).problemId)
        holder.itemView.setOnClickListener {
            val intent = Intent()

            intent.putExtra("UId",list.result.get(position).problemId)
            intent.setClass(context,QuestionXqActivity::class.java)
            context.startActivity(intent)
        }
    }

    override fun getItemCount(): Int {
        return list.result.size
    }

    class ViewHolder(itemView: View):RecyclerView.ViewHolder(itemView){

        val name: TextView

        init {
            name = itemView.findViewById<TextView>(R.id.name)

        }
    }
}